package com.gzc.just.play.last.war.sceneserver.battle.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

/**
 * 战斗记录（对应C++的SBattleResult）
 * 记录战斗的详细结果信息
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class BattleRecord implements Serializable {
    private static final long serialVersionUID = 1L;

    // ==================== 战斗基本信息 ====================
    /** 战斗ID */
    private Long battleId;
    
    /** 战斗开始时间 */
    private Long startTime;
    
    /** 战斗结束时间 */
    private Long endTime;
    
    /** 战斗持续时间（秒） */
    private Long duration;
    
    /** 地图ID */
    private Integer mapId;
    
    /** 战斗类型 */
    private String battleType;
    
    // ==================== 获胜方信息 ====================
    /** 获胜队伍ID */
    private Integer winnerTeamId;
    
    /** 获胜队伍玩家列表 */
    private List<Long> winnerPlayerIds = new ArrayList<>();
    
    // ==================== 失败方信息 ====================
    /** 失败队伍ID */
    private Integer loserTeamId;
    
    /** 失败队伍玩家列表 */
    private List<Long> loserPlayerIds = new ArrayList<>();
    
    // ==================== 统计数据 ====================
    /** 总击杀数 */
    private Integer totalKills;
    
    /** 总死亡数 */
    private Integer totalDeaths;
    
    /** 总伤害值 */
    private Long totalDamage;
    
    /** 总治疗值 */
    private Long totalHealing;
    
    // ==================== 分数统计 ====================
    /** 获胜方总分 */
    private Integer winnerScore;
    
    /** 失败方总分 */
    private Integer loserScore;
    
    // ==================== 其他信息 ====================
    /** 是否已保存 */
    private Boolean saved;
    
    /** 备注 */
    private String remarks;
    
    /**
     * 添加获胜玩家
     */
    public void addWinnerPlayer(Long playerId) {
        if (this.winnerPlayerIds == null) {
            this.winnerPlayerIds = new ArrayList<>();
        }
        this.winnerPlayerIds.add(playerId);
    }
    
    /**
     * 添加失败玩家
     */
    public void addLoserPlayer(Long playerId) {
        if (this.loserPlayerIds == null) {
            this.loserPlayerIds = new ArrayList<>();
        }
        this.loserPlayerIds.add(playerId);
    }
    
    /**
     * 增加总击杀数
     */
    public void addKill(int count) {
        this.totalKills = (this.totalKills == null ? 0 : this.totalKills) + count;
    }
    
    /**
     * 增加总死亡数
     */
    public void addDeath(int count) {
        this.totalDeaths = (this.totalDeaths == null ? 0 : this.totalDeaths) + count;
    }
    
    /**
     * 增加总伤害
     */
    public void addDamage(long damage) {
        this.totalDamage = (this.totalDamage == null ? 0L : this.totalDamage) + damage;
    }
    
    /**
     * 增加总治疗
     */
    public void addHealing(long healing) {
        this.totalHealing = (this.totalHealing == null ? 0L : this.totalHealing) + healing;
    }
}
